package com.sky.handler;

import org.springframework.security.access.AccessDecisionManager;
import org.springframework.security.core.GrantedAuthority;

/**
 * @projectName: netty-cloud
 * @package: com.sky.handler
 * @className: MyGrantedAuthority
 * @author: zhl
 * @description: 权限标识
 * @date: 2024/4/25 15:37
 * @version: 1.0
 */
public class MyGrantedAuthority implements GrantedAuthority {

    private String grantedAuthority;

    public MyGrantedAuthority(String grantedAuthority) {
        this.grantedAuthority = grantedAuthority;
    }

    /**
     * If the <code>GrantedAuthority</code> can be represented as a <code>String</code>
     * and that <code>String</code> is sufficient in precision to be relied upon for an
     * access control decision by an {@link AccessDecisionManager} (or delegate), this
     * method should return such a <code>String</code>.
     * <p>
     * If the <code>GrantedAuthority</code> cannot be expressed with sufficient precision
     * as a <code>String</code>, <code>null</code> should be returned. Returning
     * <code>null</code> will require an <code>AccessDecisionManager</code> (or delegate)
     * to specifically support the <code>GrantedAuthority</code> implementation, so
     * returning <code>null</code> should be avoided unless actually required.
     *
     * @return a representation of the granted authority (or <code>null</code> if the
     * granted authority cannot be expressed as a <code>String</code> with sufficient
     * precision).
     */
    @Override
    public String getAuthority() {
        return this.grantedAuthority;
    }
}
